<template>
	<view class="content">
		<page-head :title="title"></page-head>
		<view class="uni-padding-wrap uni-common-mt">
			<view class="text-box" scroll-y="true">
				<text>{{text}}</text>
			</view>
			<view class="uni-btn-v">
				<button type="primary" @click="scan()">扫码绑定</button>

			</view>
		</view>
		
		<Modal
			v-model="show1" 
			title='温馨提示' 
			text="绑定成功等待技术人员调试上机"
			confirm-text='确定'
			noCancel=false
			@confirm='confirm()'
		/>
	</view>
</template>

<script>
	let App = getApp();
	import Modal from '@/components/x-modal/x-modal'
	export default {
		components: {
			Modal
		},
		data(){
			return{
				text: '文字描述文字描述文字描述，文字描述文字描述，文字描述文字描述',
				show1:false
			}
		},
		onLoad() {
			
		},
		onReady() {
			this.getText();
		},
		methods:{
			getText(){
				uni.showLoading({
					title:"加载中"
				})
				this.$api.interfaceApi('getText')({
					type:2,
					admin:App.globalData.sys
				}).then(res=>{
					if(res.code == 200){
						this.text = res.data.content
						
					}
					uni.hideLoading()
				}) 
			},
			scan(){
				let _this = this
				uni.scanCode({
				    onlyFromCamera: true,
				    success: function (res) {
					   _this.add(res.result);
				    }
				});
			},
			add(code){
				let userinfo = uni.getStorageSync('userinfo');
				this.$api.interfaceApi('add')({
					'code':code,
					"id":userinfo.id
				}).then(res=>{
					if(res.code == 200){
						this.show1 = true
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				}) 
			},
			confirm(){
				uni.switchTab({
					url:'/pages/equipment/index'
				})
			},
			cancel(e){
				this.show1= false
			},
		}
	}
</script>

<style lang="less" scoped>
	.content{
		padding: 60rpx 30rpx;
	}
	.text-box {
		margin-bottom: 40rpx;
		padding: 40rpx 40rpx;
		display: flex;
		min-height: 300rpx;
		background-color: #FFFFFF;
		justify-content: center;
		align-items: center;
		text-align: center;
		font-size: 30rpx;
		color: #353535;
		line-height: 1.8;
	}
</style>
